package com.github.pig.sales.controller;


import com.github.pig.admin.service.SysUserService;
import com.github.pig.common.constant.CommonConstant;
import com.github.pig.common.util.R;
import com.github.pig.common.vo.UserVO;
import com.github.pig.sales.service.ISalesFollowUpTeamService;
import com.github.pig.training.entity.TrainingStudent;
import com.github.pig.training.service.ITrainingStudentService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.Date;

@RestController
@RequestMapping("/salesIntentionEntry")
public class SalesIntentionEntryController {

    @Autowired
    private ITrainingStudentService trainingStudentService;

    @Autowired
    private SysUserService userService;

    @Autowired
    private ISalesFollowUpTeamService teamService;
    /**
     * 添加
     * @param  trainingStudent  实体
     * @return success/false
     */
    @PostMapping
    public R<Boolean> add(@RequestBody TrainingStudent trainingStudent, UserVO user) {
        int userId = userService.findUserByUsername(user.getUsername()).getUserId();
        trainingStudent.setFollowUpStatus("1602");
        trainingStudent.setCollectUser(userId);
        trainingStudent.setCreateUser(userId);
        trainingStudent.setCreateTime(new Date());
        trainingStudent.setUpdateTime(new Date());
        trainingStudent.setCallCount(1);
        trainingStudent.setVersion(0);
        trainingStudent.setDelFlag(CommonConstant.STATUS_NORMAL);
        return new R<>(trainingStudentService.insert(trainingStudent));
    }

}
